Skip to content

feat(frontend): Where clause on impl#5320

Merged
vezenovm merged 10 commits intomasterfrom
mv/impl-where-clause
Jun 24, 2024
Merged

feat(frontend): Where clause on impl#5320
vezenovm merged 10 commits intomasterfrom
mv/impl-where-clause

Conversation

@vezenovm
Copy link
Copy Markdown
Contributor

@vezenovm vezenovm commented Jun 24, 2024

Description

Problem*

Resolves #4508

Summary*

This enables the simple functionality of being able to declare a where clause directly on a struct implementation such as below:

impl<T> MyStruct<T> where T: MyEq {
    fn my_eq(self, other: Self) -> bool {
        (self.a == other.a) & self.b.my_eq(other.b)
    }
}

The code above is essentially syntactic sugar where we every method in the struct impl has a where clause. As the logic for resolving trait constraints already exists this PR really just updates the parser to accept where clauses and during definition collection attaches them to each method in an impl.

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add where clause on an impl

2 participants